/*----------------------------------------------------------------
 * Author:          Siqi Kang
 * Written:         02/10/2014
 * Last updated:    02/10/2014
 * 
 * A bonus code set up by Manager that is used to enable customer to enjoy an 
 * extra discount during special event. 
 * 
 *----------------------------------------------------------------*/
package JavaSource;
import java.io.Serializable;
import java.util.*;



/**
 *
 * @author Siqi Kang
 * @version 1.0
 */
public class Coupon implements Serializable,IdGenerable{
   
   //Attributes 
   private static int globalId = 1000;
   private int couponID;    //identifier of a certain coupon
   private String couponCode;
   private Date beginTime;
   private Date  expirationTime;   //specify when this coupon will expire
   private double rate;  //discount rate by using this coupon

    public static int getGlobalId() {
        return globalId;
    }

    public static void setGlobalId(int globalId) {
        Coupon.globalId = globalId;
    }

 

   
    public int getCouponID() {
        return couponID;
    }

    public void setCouponID(int couponID) {
        this.couponID = couponID;
    }

    public String getCouponCode() {
        return couponCode;
    }

    public void setCouponCode(String couponCode) {
        this.couponCode = couponCode;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    
    public Date getExpirationTime() {
        return expirationTime;
    }

    public void setExpirationTime(Date expirationTime) {
        this.expirationTime = expirationTime;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }
  
    
    
    //Method

    //Constructor
    public Coupon( String couponCode, Date beginTime, Date expirationTime, double rate) {
        this.couponID = generateId();
        this.couponCode = couponCode;
        this.beginTime = beginTime;
        this.expirationTime = expirationTime;
        this.rate = rate;
    }

    @Override
    public int generateId() {
       
        return ++globalId;
    }
}
